<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:choose>
	<c:when test="${q3 != nul}">
		<p>${fn:escapeXml("#{ db.((Deal as d) where d.employee.job == '")}${q3Job}${fn:escapeXml("' and d.dealDate.year >= ")}${q3Year}})</p>

		<form class="form-horizontal">
			<input type="hidden" name="activeTab" value="q3" />
			<div class="control-group">
				<label class="control-label" for="q3Job" style="margin-right: 5px;">Job name: </label>
				<select placeholder="q3Job" id="q2StreetName" name="q3Job">
				  <option ${q3Job == 'szef' ? 'selected="true"' : ''}>szef</option>
				  <option ${q3Job == 'sprzedawca' ? 'selected="true"' : ''}>sprzedawca</option>
				  <option ${q3Job == 'manager' ? 'selected="true"' : ''}>manager</option>
				</select>
			</div>
			<div class="control-group">
				<label class="control-label" for="q3Year" style="margin-right: 5px;">Deal year </label>
				<input type="text" id="q3Year" placeholder="q2StreetName" name="q3Year" value="${q3Year}">
			</div>
			<div class="control-group" style="margin-left: 200px;">
				<button class="btn" type="submit">Search!</button>
			</div>
		</form>

		<table class="table table-hover">
			<thead>
				<tr>
					<th>Klient</th>
					<th>Pracownik</th>
					<th>Koszt</th>
					<th>Data</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="deal" items="${q3}">
					<tr>
						<td>
							<c:out value="${deal.customer.firstName}"/> <c:out value="${deal.customer.lastName}"/>
						</td>
						<td>
							<c:out value="${deal.employee.firstName}"/> <c:out value="${deal.employee.lastName}"/>
						</td>
						<td>
							<c:out value="${deal.cost}" />
						</td>
						<td>
							${deal.dealDate.year}-${deal.dealDate.month}-${deal.dealDate.day} ${deal.dealDate.hour}:${deal.dealDate.minute}
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:when>
	<c:otherwise>
		<p>Sorry no data found ;(</p>
	</c:otherwise>
</c:choose>